package com.atguigu.jxc.controller;

import com.atguigu.jxc.service.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/goodsType")
public class GoodsTypeController {

    @Autowired
    private GoodsTypeService goodsTypeService;

    @PostMapping("/loadGoodsType")
    public String loadGoodsType(){
        return goodsTypeService.loadGoodsType();
    }

    @PostMapping("/save")
    public String save(@RequestParam(required = false)String goodsTypeName,
                       @RequestParam(required = false)Integer pId){
        return goodsTypeService.save(goodsTypeName,pId);
    }

    @PostMapping("/delete")
    public String delete(@RequestParam("goodsTypeId")Integer goodsTypeId){
        return goodsTypeService.delete(goodsTypeId);
    }
}
